home *** CD-ROM | disk | FTP | other *** search
- /*
- *
- * cursor.c
- *
- * Cursor handling routines.
- *
- *
- * Author: Rob Johnston
- * Date: Friday, Janurary 17, 1992
- *
- * Copyright © 1992 Apple Computer, Inc.
- *
- */
-
- #include "globals.h"
- #include "prototypes.h"
- #include "resources.h"
-
-
- short AdjustCursor(Point theLoc, RgnHandle theRgn)
-
- { WindowPtr theWindow;
- Document *theDocument;
- RgnHandle arrowRgn, iBeamRgn, hiliteRgn;
- Rect theRect;
- Point thePoint;
- MenuHandle theMenu;
- Str255 theName;
-
- if (gInBackground)
- return;
-
- arrowRgn = NewRgn();
- SetRectRgn(arrowRgn, -32767, -32767, 32767, 32767);
-
- if ((theWindow = FrontWindow()) && (theDocument = IsDocumentWindow(theWindow))) {
- SetPort(theWindow);
- iBeamRgn = NewRgn();
- hiliteRgn = NewRgn();
-
- theRect = (**(theDocument->theTE)).viewRect;
- LocalToGlobal(&(theRect.top));
- LocalToGlobal(&(theRect.bottom));
- RectRgn(iBeamRgn, &theRect);
-
- CopyRgn(theDocument->hiliteRgn, hiliteRgn);
- thePoint.h = thePoint.v = 0;
- LocalToGlobal(&thePoint);
- OffsetRgn(hiliteRgn, thePoint.h, thePoint.v);
-
- DiffRgn(arrowRgn, hiliteRgn, arrowRgn);
- DiffRgn(arrowRgn, iBeamRgn, arrowRgn);
-
- DiffRgn(iBeamRgn, hiliteRgn, iBeamRgn);
-
- if (PtInRgn(theLoc, iBeamRgn)) {
- SetCursor(*GetCursor(iBeamCursor));
- CopyRgn(iBeamRgn, theRgn);
- } else if (PtInRgn(theLoc, hiliteRgn)) {
- SetCursor(&qd.arrow);
- CopyRgn(hiliteRgn, theRgn);
- } else {
- SetCursor(&qd.arrow);
- CopyRgn(arrowRgn, theRgn);
- }
-
- DisposeRgn(iBeamRgn);
- DisposeRgn(hiliteRgn);
- } else {
- SetCursor(&qd.arrow);
- CopyRgn(arrowRgn, theRgn);
- }
-
- DisposeRgn(arrowRgn);
- }
-
-
- short GetGlobalMouse(Point *theLoc)
-
- { EventRecord theEvent;
-
- OSEventAvail(0, &theEvent);
- *theLoc = theEvent.where;
- }
-
-